/*
 * This class is for class adapter method.It is a client with view.
 * 
 */
package client;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import adapter.ClassAdapter;

public class ClassAdapterClient {
	static JLabel labResult;
	public static void main(String[] args) {
		JFrame mainFrame = new JFrame("Class adapter client");
		
		mainFrame.setBounds(100, 100, 400, 300);
		
		JPanel mainPanel = new JPanel();
		mainPanel.setBounds(0, 0, 400, 300);
		
		JLabel lab1 = new JLabel("第一个数");
		JLabel lab2 = new JLabel("第二个数");
		
		final JTextField txf1 = new JTextField(5);
		final JTextField txf2 = new JTextField(5);
		
		JButton btnCommit = new JButton("第一个数比第二个数大？");
		btnCommit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				char a[] = null;
				char b[] = null;
				boolean res = false;
				try {
					a = txf1.getText().toCharArray();
					b = txf2.getText().toCharArray();
					res = new ClassAdapter().bigger(a, b);
				} catch (Exception e) {
					labResult.setText("输入错误");
				}
				
				
				if(res)
				{
					labResult.setText("第一个数大");
				}else
				{
					labResult.setText("第一个数不比第二个数大");
				}
			}
		});
		labResult = new JLabel();
		
		mainPanel.add(lab1);
		mainPanel.add(txf1);
		mainPanel.add(lab2);
		mainPanel.add(txf2);
		mainPanel.add(btnCommit);
		mainPanel.add(labResult);
		mainFrame.add(mainPanel);
		
		
		mainFrame.setVisible(true);
		
	}
}
